<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="jquery-3.2.1.js"></script>
    <title>电影列表jq</title>
</head>
<style>
    tbody tr td {
        text-align: center;
        width: 100px;
        border: 1px solid rgba(0, 0, 0, 0.2);
        height: 26px;
        position: relative;
    }
    
    tr th {
        width: 100px;
        border: 1px solid rgba(0, 0, 0, 0.2);
    }
    
    table {
        position: absolute;
        top: 70px;
        left: 150px;
        border-collapse: collapse;
    }
    
    .input {
        width: 100%;
        height: 100%;
        border: 1px solid red;
        position: absolute;
        left: 0;
        top: 0;
    }
    
    tfoot img {
        width: 120px;
        height: auto;
        position: relative;
    }
    
    tfoot .box {
        border-radius: 30px;
        border: 1px solid black;
        width: 80px;
        height: 40px;
        padding-left: 20px;
    }
    
    tfoot {
        position: relative;
    }
    
    tfoot .box.aa {
        background-color: blue;
        position: absolute
    }
    
    tfoot .box.bb {
        background-color: green;
        position: absolute;
        left: 130px;
    }
    
    tfoot .box.cc {
        background-color: gold;
        position: absolute;
        left: 260px;
    }
    
    tfoot .box.dd {
        background-color: red;
        position: absolute;
        left: 390px;
    }
</style>

<body>
    电影名称:<input type="text" class="film_name"> 电影评分:
    <input type="text" class="film_score"> 电影年份:
    <input type="text" class="film_year"><button class="film_add">添加</button>
    <table>
        <thead>
            <tr>
                <th>电影名称</th>
                <th>电影评分</th>
                <th>电影年份</th>
                <th>相关操作</th>
            </tr>
        </thead>
        <tbody>

        </tbody>
        <tfoot>
            <tr>
                <td><img class="kba" src="kb.jpg"></td>
                <td><img class="kbb" src="kb.jpg"></td>
                <td><img class="kbc" src="kb.jpg"></td>
                <td><img class="kbd" src="kb.jpg"></td>
            </tr>
        </tfoot>
    </table>
</body>
<script>
    $(function() {
        var tbody = $("tbody");
        var add = $(".film_add");
        add.on("click", function(e) {
            var name = $(".film_name").val();
            var score = $(".film_score").val();
            var year = $(".film_year").val();

            if (name != "" && score != "" && year != "") {
                var content = "<tr><td>" + name + "</td><td>" + score + "</td><td>" + year + "</td><td>" + "<button class='film_delete'>删除</button>" + "</td></tr>"
                var jContent = $(content);
                jContent.appendTo(tbody);

                var deletes = $(".film_delete");
                deletes.off("click");
                deletes.on("click", function(e) {
                    var tr = $(this).parents("tr");
                    tr.remove();
                })
                $("td").on("dblclick", function(e) {
                    var hInput = "<input type='text' class='input'></input>";
                    var jInput = $(hInput);
                    var td = $(this);
                    td.append(hInput);
                    $(".input").focus();
                    $(".input").on("blur", function(e) {
                        // if (jInput.val() == "") {
                        //     var tr = $(this).parents("tr");
                        //     tr.remove();
                        //     var content = "<tr><td>" + name + "</td><td>" + score + "</td><td>" + year + "</td><td>" + "<button class='film_delete'>删除</button>" + "</td></tr>"
                        //     var jContent = $(content);
                        //     jContent.appendTo(tbody);
                        // } else {
                        td.text($(".input").val());
                        $(".input").remove();
                        // }
                    })
                })
            } else {
                var contents = "";
                var jContent = $(contents);
                jContent.appendTo(tbody);
            }
        })

        $(".kba").on("mouseenter", function(e) {
            var hbox = "<div class='box aa'>tooptip</div>";
            var jbox = $(hbox);
            var td = $(this);
            $("tfoot").append(hbox);
        })
        $(".kba").on("mouseleave", function(e) {
            var box = $(".aa");
            box.remove();

        })
        $(".kbb").on("mouseenter", function(e) {
            var hbox = "<div class='box bb'>tooptip</div>";
            var jbox = $(hbox);
            var td = $(this);
            $("tfoot").append(hbox);
        })
        $(".kbb").on("mouseleave", function(e) {
            var box = $(".bb");
            box.remove();

        })
        $(".kbc").on("mouseenter", function(e) {
            var hbox = "<div class='box cc'>tooptip</div>";
            var jbox = $(hbox);
            var td = $(this);
            $("tfoot").append(hbox);
        })
        $(".kbc").on("mouseleave", function(e) {
            var box = $(".cc");
            box.remove();

        })
        $(".kbd").on("mouseenter", function(e) {
            var hbox = "<div class='box dd'>tooptip</div>";
            var jbox = $(hbox);
            var td = $(this);
            $("tfoot").append(hbox);
        })
        $(".kbd").on("mouseleave", function(e) {
            var box = $(".dd");
            box.remove();

        })
    })
</script>

</html>